package org.arclib.time;

/// Code good for anything that can blink
public class Blinker
{
	public boolean on = false;
	public double lastTime = 0, currTime = 0;
	public double totalsec = 0.0f;

	public Blinker()
	{
		lastTime = Time.getTime();
		currTime = Time.getTime() + .01; // make sure current starts out bigger
											// than lastTime
	}

	// / blinker is on every # of seconds
	public void process(double argSeconds)
	{
		lastTime = currTime; // last time equals what curr time was
		currTime = Time.getTime(); // update curr time to the current time

		double seconds = currTime - lastTime;
		seconds /= 1000;

		totalsec += seconds;

		on = false;

		if (totalsec > argSeconds) // if totalsec has elapsed since the last
									// time
		{
			on = true;
			totalsec = 0;
		}
	}
}
